1. Field of the Invention
The present invention relates to a multitasking operating system.
2. Related Art
In some of computer systems, the CPU of a microcomputer operates in a normal mode and a low-power-consumption (LPC) mode. In the LPC mode, the CPU operates at a lower clock frequency or supply of the clock is suppressed for reducing power consumption. When the CPU switches from the normal mode to the LPC mode, execution of some programs is stopped. Therefore the computer system includes a dedicated program which determines proper time for switching from the normal mode to the LPC mode and proper duration of the LPC mode. Thereby the CPU is switched between the normal mode and LPC mode so that the operation of the computer system is not disrupted.
A door electronic control unit (ECU), which is a computer system that includes a microcomputer, controls the door lock in a vehicle switching between a normal mode and an intermittent mode (i.e., LPC mode). Referring to FIG. 8, the door ECU in the normal mode executes processes A, B, C, . . . , n every 5 ms, for example. Each of the processes A, B, C, . . . , n is an application program which implements a predetermined function. For example, the process A implements a keyless entry system, while the process B implements a door lock system.
Each of the processes A, B, C, . . . , n sets a flag, which indicates whether the LPC mode is acceptable or not, during the execution. The process B sets the flag on for indicating that the process B can accept the LPC mode, if the elapsed time after the doors are locked reaches ten minutes.
After the execution of the processes A, B, C, . . . , n completes, a manager process determines whether the CPU should operate in the normal mode or the LPC mode based on the flags. If all the flags are on, that is, all the processes A, B, C, . . . , n can accept the LPC mode, the manager sets the CPU in the LPC mode. If at least one of the flags are off, the manager sets the CPU in the normal mode.
Referring to FIG. 9, in the normal mode, the CPU executes the processes A, B, C, . . . , n every 5 ms (T1) as described above. However, the CPU may execute the processes A, B, C, . . . , n every 300 ms (T2), and then the CPU is set in the LPC mode during a time interval T3 between the completion of execution of the processes A, B, C, . . . , n and the beginning of next execution of the processes A, B, C, . . . , n. Thus the CPU is switched between the normal mode and the LPC mode so that the execution of the processes A, B, C, . . . , n is not disrupted.
However, a series of processes A, B, C, . . . , n to be repeatedly executed at regular intervals is difficult to program on a large scale. Further time (T0 in FIG. 9) required for executing the series of processes A, B, C, . . . , n may be sometimes long, and the responsiveness of the system is lowered in this case. In order to overcome this problem, a multitasking operating system such as a real time operating system (RTOS) is employed. The multitasking operating system treats a plurality of processes of a program as tasks, and executes the program switching tasks. Thus the multitasking operating system includes not only a mechanism for regularly executing a program, but also a mechanism for executing a program circumstantially switching tasks.
When the multitasking operating system executes a program switching tasks, the states of the tasks are always changing according to the priority and depending on occurrence of interrupts and issue of system calls. Accordingly a time interval between the completion of execution of the tasks and the beginning of next execution of the tasks cannot be easily estimated. Further the proper time for switching the CPU into the LPC mode cannot be easily determined.